package cmd

import (
	"fsd/client"
	"fsd/impl"
	"fsd/logger"
	"github.com/spf13/cobra"
)

var cliCmd = &cobra.Command{
	Use:   "cli",
	Short: "start cli",
	Long:  "start cli",
	Run:   startCli,
}

// var cmdNewGameId uint64
// var cmdNewGameUserIds []int

func init() {
	// newGameCmd.PersistentFlags().Uint64Var(&cmdNewGameId, "gameid", 0, "spec a new game id")
	// newGameCmd.PersistentFlags().IntSliceVar(&cmdNewGameUserIds, "userids", nil, "spec user id list")
	// newGameCmd.MarkPersistentFlagRequired("gameid")
	// newGameCmd.MarkPersistentFlagRequired("userids")
	rootCmd.AddCommand(cliCmd)
}

func startCli(cmd *cobra.Command, args []string) {
	logger.InitLogger(cfgData.Server.LogEnv, cfgData.Server.LogLevel, cfgData.Server.LogPath)

	initFightServerConfig()
	client.CM.GameProtocoler = &impl.GameProtocol{}
	client.CM.ServerAddr = cfgData.Server.LAddr
	for _, userId := range cfgData.Test.TestUserIds {
		client.CM.U2G[userId] = cfgData.Test.TestGameId
	}
	client.StartClients()
}
